#include <iostream>
#include <boost/program_options.hpp>
#include <string>
#include <math.h>
#include <fstream>
#include <boost/filesystem/path.hpp>
#include <iostream>
#include <string>
#include <stdio.h>
#include <math.h>
#include "get_arg.h"


// link with -lboost_filesystem-gcc -lboost_program_options-gcc
// program_options_helper.cpp

#define DEBUG_LEVEL 6
#include <debug_func.h>


// my functions
#include <matrix_formats.h>
#include <print_error.h>
#include <program_options_helper.h>

using std::ofstream;
using std::ifstream;
using std::cout;
using std::string;
using std::vector;
using std::cerr;
using namespace program_options_helper;
namespace po = boost::program_options_lg;


//_______________________________________________________________________________________

//		process_command_line_options

//				from command line
//				Created [9/13/2001]

//_______________________________________________________________________________________


bool process_command_line_options(int argc, char* argv[], t_program_args& args)
{
	string dbname;
	po::options_description mandatory_args("Mandatory Arguments");
	mandatory_args.add_options()
	("prot_id_to_gene_id,p", po::value<string>(&args.prot_to_gene_id)->set_name("FILE"),
									"Contains protein identifiers in the first column "
									"tab-separated from the second column of gene "
									"identifiers.")
	("input_prot_pairs,i", po::value<string>(&args.gene_prot_pairs)->set_name("FILE"),
									"Holds the best hitting transcript "
									"pairs in a tab-delimited format.\1"
									"(gene_id1, gene_id2, prot_id1, prot_id2).")
	("output_prot_pairs,o", po::value<string>(&args.prot_pairs)->set_name("FILE"),
									"Holds the clustered best hitting protein identifier "
									"pairs in a tab-delimited format.")
	("clusters,c", po::value<string>(&args.clusters)->set_name("FILE"),
									"Holds lists of clustered genes.")
	("sizes,s", po::value<string>(&args.sizes)->set_name("FILE"),
									"Holds lists of cluster sizes.");



	args.add_std_options();
	po::options_description all_args("");
	all_args.add(mandatory_args).add(args.optional_args);

	po::options_description visible_args("");
	visible_args.add(mandatory_args).add(args.optional_args);

	// parse command line
	po::variables_map vm;
	po::store(po::command_line_parser(argc, argv)
								.options(all_args)
								.run(), vm);
	po::notify(vm);


	if (vm.count("version"))
	{
		print_version(cerr, *argv, "1.0");
		return false;
	}
	if (vm.count("help"))
	{
		string exe_description =
							"Orders best hitting transcript by single linkage defined gene "
							"clusters\n";

		print_usage(cerr, string(*argv),
											"--prot_id_to_gene_id FILE \n"
											"--input_prot_pairs FILE \n"
											"--output_prot_pairs FILE \n"
											"--clusters FILE \n"
											"--sizes FILE\n"
											"[OPTIONS]",
	    					visible_args, exe_description, 80);
		return false;
	}

	check_required_options(vm, mandatory_args);
	args.open_err_log();



	return true;
}

